//
//  MCReuse_entryView.swift
//  StoreManage
//
//  Created by MC on 2018/5/17.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit

/**
 *  说明
 *  元素： icon  title  detail  arow  lineView  图片，标题，详情，箭头，基线
 */

class MCReuse_entryView: UIView {

    /**
     是否展示箭头
     */
    var isShowArrow = false {
        didSet {
            var width = 0
            
            if isShowArrow {
                width = 8
            } else {
                width = 0
            }
            
            
            arrowImageView.snp.remakeConstraints { (make) ->Void in
                make.centerY.equalTo(self)
                make.right.equalTo(self).offset(-10)
                make.size.equalTo(CGSize.init(width: width, height: 14))
            }
            
            detailLabel.snp.remakeConstraints { (make) ->Void in
                make.centerY.equalTo(self)
                make.right.equalTo(arrowImageView.snp.left).offset(-5)
            }

        }
    }
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(lineView)
        lineView.snp.remakeConstraints { (make) ->Void in
            make.left.right.bottom.equalTo(self)
            make.height.equalTo(1)
        }
        
        self.addSubview(iconImageView)
        iconImageView.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.left.equalTo(self).offset(10)
        }

        
        self.addSubview(titleLabel)
        titleLabel.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.left.equalTo(iconImageView.snp.right).offset(0)
        }
        
        self.addSubview(arrowImageView)
        self.addSubview(detailLabel)
        detailLabel.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.right.equalTo(self).offset(-10)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()
    
    lazy var iconImageView: UIImageView = {
        let imageView = UIImageView()
        return imageView
    }()
    
    public lazy var titleLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCWords
        return label
    }()

    public lazy var detailLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCWords
        return label
    }()
    
    lazy var arrowImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "Reuse_arrow")
        return imageView
    }()

}
